close all
clear all
clc

ids = [];
NumClas = [];
NumFeat = [];
NumSamp = [];
IRs = [];

for c = [2 3 4 5],
    for f = [2 3 4 5],
        load(['../bases/DataSet' num2str(c) 'C' num2str(f) 'F'])
        id = 10*c+f;
        N = max(Labels(:));
        F = size(Samples,2);
        S = size(Samples,1);
        clear n
        for z = 1:c,
           n(z) = sum(Labels(:)==z); 
        end
        
        IR = max(n(:))/min(n(:));
        
        ids = [ids; id];
        NumClas = [NumClas; N];
        NumFeat = [NumFeat; F];
        NumSamp = [NumSamp; S];
        IRs = [IRs; IR];
    end
end

A = [ids NumClas NumFeat NumSamp IRs];

mt_matrix2latex(A)



%% Results analisis
BaseName = {'22' '23' '24' '25' '32' '33' '34' '35' '42' '43' '44' '45' '52' '53' '54' '55'};
TestGmeanCC = [79.4 92.1 94.8 97.8 72.0 85.4 93.3 96.2 63.6 85.7 93.3 94.4 56.2 82.7 87.9 92.8];
TrainGmeanCC = [78.4 91.2 98.2 99.1 74.7 86.8 97.7 98.2 68.2 88.1 98.0 97.9 66.3 85.1 97.6 96.7];
TestGmeanSVM = [67.9 92.8 94.9 98.4 62.7 86.6 92.8 98.2 53.1 85.5 93.2 97.2 45.9 82.2 89.9 95.8];
TrainGmeanSVM = [66.6 94.2 97.2 99.4 65.0 89.2 95.5 99.6 55.9 88.3 95.9 98.9 48.8 85.3 93.1 96.9];

TestAccuracyCC = [77.9 92.6 96.3 98.3 70.4 86.0 94.0 96.3 61.4 87.6 93.8 94.8 55.7 84.1 91.0 93.4];
TrainAccuracyCC = [77.4 91.7 99.0 99.4 72.7 87.2 97.3 98.0 65.6 89.6 97.4 97.9 64.1 86.1 98.1 97.0];
TestAccuracySVM = [84.3 94.3 96.6 98.7 75.8 89.5 95.3 98.5 68.9 89.4 95.2 97.5 62.5 86.5 93.7 96.4];
TrainAccuracySVM = [84.3 95.6 98.2 99.5 77.9 91.6 97.3 99.7 70.6 91.7 97.3 99.0 65.2 89.4 95.9 97.4];

% Sort by accuracy
[~,ind] = sort(TestAccuracySVM);

BaseName = BaseName(ind);

TestGmeanCC = TestGmeanCC(ind);
TrainGmeanCC = TrainGmeanCC(ind);
TestGmeanSVM = TestGmeanSVM(ind);
TrainGmeanSVM = TrainGmeanSVM(ind);

TestAccuracyCC = TestAccuracyCC(ind);
TrainAccuracyCC = TrainAccuracyCC(ind);
TestAccuracySVM = TestAccuracySVM(ind);
TrainAccuracySVM = TrainAccuracySVM(ind);

%%
fontsize = 15;
legpos = [0.102 0.84 0.27 0.0748];

figure('name','Gmean Test');
h = bar([TestGmeanCC; TestGmeanSVM]');
set(h(1),'FaceColor',[.2 .2 .2],'LineStyle','--');
set(h(2),'FaceColor',[.8 .8 .8]);
h = legend('OMG','SVM');
axis tight;
set(h,'Position',legpos,'fontname','AvantGarde','FontSize', fontsize,'fontweight','b');
set(gca,'XTick',[1:16],'XTickLabel',BaseName,'fontname','AvantGarde','FontSize', fontsize);
xlabel('Base Id','fontname','AvantGarde','FontSize', fontsize,'fontweight','b'); 
ylabel('Gmean %','FontName','AvantGarde','FontSize', fontsize,'fontweight','b'); 
title('Test','FontName','AvantGarde','FontSize', fontsize,'fontweight','b');
print('-depsc', 'GmeanTest');

figure('name','Gmean Train');
h = bar([TrainGmeanCC; TrainGmeanSVM]');
set(h(1),'FaceColor',[.2 .2 .2],'LineStyle','--');
set(h(2),'FaceColor',[.8 .8 .8]);
h = legend('OMG','SVM'); axis tight;
set(h,'Position',legpos,'fontname','AvantGarde','FontSize', fontsize,'fontweight','b');
set(gca,'XTick',[1:16],'XTickLabel',BaseName,'fontname','AvantGarde','FontSize', fontsize);
xlabel('Base Id','fontname','AvantGarde','FontSize', fontsize,'fontweight','b'); 
ylabel('Gmean %','FontName','AvantGarde','FontSize', fontsize,'fontweight','b'); 
title('Train','FontName','AvantGarde','FontSize', fontsize,'fontweight','b');
print('-depsc', 'GmeanTrain');

figure('name','Accuracy Test');
h = bar([TestAccuracyCC; TestAccuracySVM]');
set(h(1),'FaceColor',[.2 .2 .2],'LineStyle','--');
set(h(2),'FaceColor',[.8 .8 .8]);
h = legend('OMG','SVM'); axis tight;
set(h,'Position',legpos,'fontname','AvantGarde','FontSize', fontsize,'fontweight','b');
set(gca,'XTick',[1:16],'XTickLabel',BaseName,'fontname','AvantGarde','FontSize', fontsize);
xlabel('Base Id','fontname','AvantGarde','FontSize', fontsize,'fontweight','b'); 
ylabel('Accuracy %','FontName','AvantGarde','FontSize', fontsize,'fontweight','b'); 
title('Test','FontName','AvantGarde','FontSize', fontsize,'fontweight','b');
print('-depsc', 'AccuracyTest');

figure('name','Accuracy Train');
h = bar([TrainAccuracyCC; TrainAccuracySVM]');
set(h(1),'FaceColor',[.2 .2 .2],'LineStyle','--');
set(h(2),'FaceColor',[.8 .8 .8]);
h = legend('OMG','SVM'); axis tight;
set(h,'Position',legpos,'fontname','AvantGarde','FontSize', fontsize,'fontweight','b');
set(gca,'XTick',[1:16],'XTickLabel',BaseName,'fontname','AvantGarde','FontSize', fontsize);
xlabel('Base Id','fontname','AvantGarde','FontSize', fontsize,'fontweight','b'); 
ylabel('Accuracy %','FontName','AvantGarde','FontSize', fontsize,'fontweight','b'); 
title('Train','FontName','AvantGarde','FontSize', fontsize,'fontweight','b');
print('-depsc', 'AccuracyTrain');











%